package com.gzhu.knowledgeAdmin.controller;

import com.gzhu.knowledgeAdmin.common.result.R;
import com.gzhu.knowledgeAdmin.common.vo.OperatorVo;
import com.gzhu.knowledgeAdmin.common.vo.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.gzhu.knowledgeAdmin.entity.Operator;
import com.gzhu.knowledgeAdmin.service.OperatorService;

import java.util.Map;
import java.util.List;

/**
 * 算子表
 *
 * @author yangminggui
 * @email giaogiao@gmail.com
 * @date 2024-01-25 23:16:07
 */
@RestController
@RequestMapping("knowledgeAdmin/operator")
public class OperatorController {
    @Autowired
    private OperatorService operatorService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageVo page = operatorService.queryPage(params);
        return R.ok(page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
        OperatorVo operatorVo  = operatorService.getOperatorById(id);
        return R.ok(operatorVo);
    }

    /**
     * 添加
     */
    @PostMapping("/save")
    public R save(@RequestBody OperatorVo operatorVo){
		Operator operator = operatorService.saveOrUpdateOperator(operatorVo);
        return R.ok(operator);
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody OperatorVo operatorVo){
        Operator operator = operatorService.saveOrUpdateOperator(operatorVo);
        return R.ok(operator);
    }


    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody List<Integer> ids){
		operatorService.removeByIds(ids);
        return R.ok();
    }

}
